home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 15 / CU Amiga Magazine's Super CD-ROM 15 (1997)(EMAP Images)(GB)[!][issue 1997-10].iso / CUCD / Graphics / Ghostscript / source / libpng / pngconf.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-15  |  14.7 KB  |  446 lines

  1.  
  2. /* pngconf.c - machine configurable file for libpng
  3.  
  4.    libpng 1.0 beta 6 - version 0.96
  5.    For conditions of distribution and use, see copyright notice in png.h
  6.    Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
  7.    Copyright (c) 1996, 1997 Andreas Dilger
  8.    May 12, 1997
  9.    */
  10.  
  11. /* Any machine specific code is near the front of this file, so if you
  12.    are configuring libpng for a machine, you may want to read the section
  13.    starting here down to where it starts to typedef png_color, png_text,
  14.    and png_info */
  15.  
  16. #ifndef PNGCONF_H
  17. #define PNGCONF_H
  18.  
  19. /* This is the size of the compression buffer, and thus the size of
  20.    an IDAT chunk.  Make this whatever size you feel is best for your
  21.    machine.  One of these will be allocated per png_struct.  When this
  22.    is full, it writes the data to the disk, and does some other
  23.    calculations.  Making this an extreamly small size will slow
  24.    the library down, but you may want to experiment to determine
  25.    where it becomes significant, if you are concerned with memory
  26.    usage.  Note that zlib allocates at least 32Kb also.  For readers,
  27.    this describes the size of the buffer available to read the data in.
  28.    Unless this gets smaller then the size of a row (compressed),
  29.    it should not make much difference how big this is.  */
  30.  
  31. #define PNG_ZBUF_SIZE 8192
  32.  
  33. /* If you are running on a machine where you cannot allocate more
  34.    than 64K of memory at once, uncomment this.  While libpng will not
  35.    normally need that much memory in a chunk (unless you load up a very
  36.    large file), zlib needs to know how big of a chunk it can use, and
  37.    libpng thus makes sure to check any memory allocation to verify it
  38.    will fit into memory.
  39. #define PNG_MAX_MALLOC_64K
  40. */
  41. #if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K)
  42. #define PNG_MAX_MALLOC_64K
  43. #endif
  44.  
  45. /* This protects us against compilers which run on a windowing system
  46.    and thus don't have or would rather us not use the stdio types:
  47.    stdin, stdout, and stderr.  The only one currently used is stderr
  48.    in png_error() and png_warning().  #defining PNG_NO_STDIO will
  49.    prevent these from being compiled and used. */
  50.  
  51. /* #define PNG_NO_STDIO */
  52.  
  53. /* for FILE.  If you are not using standard io, you don't need this */
  54. #ifndef PNG_NO_STDIO
  55. #include <stdio.h>
  56. #endif
  57.  
  58. /* This macro protects us against machines that don't have function
  59.    prototypes (ie K&R style headers).  If your compiler does not handle
  60.    function prototypes, define this macro and use the included ansi2knr.
  61.    I've always been able to use _NO_PROTO as the indicator, but you may
  62.    need to drag the empty declaration out in front of here, or change the
  63.    ifdef to suit your own needs. */
  64. #ifndef PNGARG
  65.  
  66. #ifdef OF /* zlib prototype munger */
  67. #define PNGARG(arglist) OF(arglist)
  68. #else
  69.  
  70. #ifdef _NO_PROTO
  71. #define PNGARG(arglist) ()
  72. #else
  73. #define PNGARG(arglist) arglist
  74. #endif /* _NO_PROTO */
  75.  
  76. #endif /* OF */
  77.  
  78. #endif /* PNGARG */
  79.  
  80. /* Try to determine if we are compiling on a Mac */
  81. #if defined(__MWERKS__) ||defined(applec) ||defined(THINK_C) ||defined(__SC__)
  82. #define MACOS
  83. #endif
  84.  
  85. /* enough people need this for various reasons to include it here */
  86. #if !defined(MACOS) && !defined(RISCOS)
  87. #include <sys/types.h>
  88. #endif
  89.  
  90. /* This is an attempt to force a single setjmp behaviour on Linux.  If
  91.    the X config stuff didn't define _BSD_SOURCE we wouldn't need this. */
  92. #ifdef linux
  93. #ifdef _BSD_SOURCE
  94. #define _PNG_SAVE_BSD_SOURCE
  95. #undef _BSD_SOURCE
  96. #endif
  97. #ifdef _SETJMP_H
  98. #error  __png_h_already_includes_setjmp_h__
  99. #error  __dont_include_it_again__
  100. #endif
  101. #endif /* linux */
  102.  
  103. /* include setjmp.h for error handling */
  104. #include <setjmp.h>
  105.  
  106. #ifdef linux
  107. #ifdef _PNG_SAVE_BSD_SOURCE
  108. #define _BSD_SOURCE
  109. #undef _PNG_SAVE_BSD_SOURCE
  110. #endif
  111. #endif /* linux */
  112.  
  113. #ifdef BSD
  114. #include <strings.h>
  115. #else
  116. #include <string.h>
  117. #endif
  118.  
  119. /* Other defines for things like memory and the like can go here.  */
  120. #ifdef PNG_INTERNAL
  121. #include <stdlib.h>
  122. /* Where do we need this???
  123. #include <ctype.h>
  124. */
  125.  
  126. /* The functions exported by PNG_EXTERN are PNG_INTERNAL functions, which
  127.  * aren't usually used outside the library (as far as I know), so it is
  128.  * debatable if they should be exported at all.  In the future, when it is
  129.  * possible to have run-time registry of chunk-handling functions, some of
  130.  * these will be made available again.
  131. #define PNG_EXTERN extern
  132.  */
  133. #define PNG_EXTERN
  134.  
  135. /* Other defines specific to compilers can go here.  Try to keep
  136.    them inside an appropriate ifdef/endif pair for portability */
  137.  
  138. #if defined(MACOS)
  139. /* We need to check that <math.h> hasn't already been included earlier
  140.    as it seems it doesn't agree with <fp.h>, yet we should really use
  141.    <fp.h> if possible. */
  142. #if !defined(__MATH_H__) && !defined(__MATH_H) && !defined(__cmath__)
  143. #include <fp.h>
  144. #endif
  145. #else
  146. #include <math.h>
  147. #endif
  148.  
  149. /* For some reason, Borland C++ defines memcmp, etc. in mem.h, not
  150.    stdlib.h like it should (I think).  Or perhaps this is a C++
  151.    "feature"? */
  152. #ifdef __TURBOC__
  153. #include <mem.h>
  154. #include "alloc.h"
  155. #endif
  156.  
  157. #ifdef _MSC_VER
  158. #include <malloc.h>
  159. #endif
  160.  
  161. /* This controls how fine the dithering gets.  As this allocates
  162.    a largish chunk of memory (32K), those who are not as concerned
  163.    with dithering quality can decrease some or all of these. */
  164. #define PNG_DITHER_RED_BITS 5
  165. #define PNG_DITHER_GREEN_BITS 5
  166. #define PNG_DITHER_BLUE_BITS 5
  167.  
  168. /* This controls how fine the gamma correction becomes when you
  169.    are only interested in 8 bits anyway.  Increasing this value
  170.    results in more memory being used, and more pow() functions
  171.    being called to fill in the gamma tables.  Don't set this
  172.    value less then 8, and even that may not work (I haven't tested
  173.    it). */
  174.  
  175. #define PNG_MAX_GAMMA_8 11
  176.  
  177. /* This controls how much a difference in gamma we can tolerate before
  178.    we actually start doing gamma conversion.  */
  179. #define PNG_GAMMA_THRESHOLD 0.05
  180.  
  181. #endif /* PNG_INTERNAL */
  182.  
  183. /* The following uses const char * instead of char * for error
  184.    and warning message functions, so some compilers won't complain.
  185.    If you want to use const, define PNG_USE_CONST here.  It is not
  186.    normally defined to make configuration easier, as it is not a
  187.    critical part of the code.
  188.    */
  189. #undef PNG_USE_CONST
  190.  
  191. #ifdef PNG_USE_CONST
  192. #  define PNG_CONST const
  193. #else
  194. #  define PNG_CONST
  195. #endif
  196.  
  197. /* The following defines give you the ability to remove code from the
  198.    library that you will not be using.  I wish I could figure out how to
  199.    automate this, but I can't do that without making it seriously hard
  200.    on the users.  So if you are not using an ability, change the #define
  201.    to and #undef, and that part of the library will not be compiled.  If
  202.    your linker can't find a function, you may want to make sure the
  203.    ability is defined here.  Some of these depend upon some others being
  204.    defined.  I haven't figured out all the interactions here, so you may
  205.    have to experiment awhile to get everything to compile.  If you are
  206.    creating or using a shared library, you probably shouldn't touch this,
  207.    as it will affect the size of the structures, and this will cause bad
  208.    things to happen if the library and/or application ever change. */
  209.  
  210. /* Any transformations you will not be using can be undef'ed here */
  211. #define PNG_PROGRESSIVE_READ_SUPPORTED
  212. #define PNG_READ_OPT_PLTE_SUPPORTED
  213. #define PNG_READ_INTERLACING_SUPPORTED
  214. #define PNG_READ_EXPAND_SUPPORTED
  215. #define PNG_READ_SHIFT_SUPPORTED
  216. #define PNG_READ_PACK_SUPPORTED
  217. #define PNG_READ_BGR_SUPPORTED
  218. #define PNG_READ_SWAP_SUPPORTED
  219. #define PNG_READ_PACKSWAP_SUPPORTED
  220. #define PNG_READ_INVERT_SUPPORTED
  221. #define PNG_READ_DITHER_SUPPORTED
  222. #define PNG_READ_BACKGROUND_SUPPORTED
  223. #define PNG_READ_16_TO_8_SUPPORTED
  224. #define PNG_READ_FILLER_SUPPORTED
  225. #define PNG_READ_GAMMA_SUPPORTED
  226. #define PNG_READ_GRAY_TO_RGB_SUPPORTED
  227. #define PNG_READ_SWAP_ALPHA_SUPPORTED
  228. #define PNG_READ_STRIP_ALPHA_SUPPORTED
  229.  
  230. #define PNG_WRITE_INTERLACING_SUPPORTED
  231. #define PNG_WRITE_SHIFT_SUPPORTED
  232. #define PNG_WRITE_PACK_SUPPORTED
  233. #define PNG_WRITE_BGR_SUPPORTED
  234. #define PNG_WRITE_SWAP_SUPPORTED
  235. #define PNG_WRITE_PACKSWAP_SUPPORTED
  236. #define PNG_WRITE_INVERT_SUPPORTED
  237. #define PNG_WRITE_FILLER_SUPPORTED  /* This is the same as WRITE_STRIP_ALPHA */
  238. #define PNG_WRITE_FLUSH_SUPPORTED
  239. #define PNG_WRITE_SWAP_ALPHA_SUPPORTED
  240. #define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
  241.  
  242. /* These are currently experimental features */
  243. #undef PNG_READ_16_TO_8_ACCURATE_SHIFT_SUPPORTED /* very little testing */
  244. #undef PNG_READ_COMPOSITE_NODIV_SUPPORTED        /* very little testing */
  245.  
  246. /* This is only for PowerPC big-endian and 680x0 systems */
  247. #undef PNG_READ_BIG_ENDIAN_SUPPORTED             /* some testing */
  248.  
  249. /* These functions are turned off by default, as they will be phased out. */
  250. #undef  PNG_USE_OWN_CRC
  251. #undef  PNG_USELESS_TESTS_SUPPORTED
  252. #undef  PNG_CORRECT_PALETTE_SUPPORTED
  253.  
  254. /* Any chunks you are not interested in, you can undef here.  The
  255.  * ones that allocate memory may be expecially important (hIST,
  256.  * tEXt, zTXt, tRNS, pCAL).  Others will just save time and make png_info
  257.  * a bit smaller.  OPT_PLTE only disables the optional palette in RGB
  258.  * and RGBA images.
  259.  */
  260.  
  261. #define PNG_READ_bKGD_SUPPORTED
  262. #define PNG_READ_cHRM_SUPPORTED
  263. #define PNG_READ_gAMA_SUPPORTED
  264. #define PNG_READ_hIST_SUPPORTED
  265. #define PNG_READ_oFFs_SUPPORTED
  266. #define PNG_READ_pCAL_SUPPORTED
  267. #define PNG_READ_pHYs_SUPPORTED
  268. #define PNG_READ_sBIT_SUPPORTED
  269. #define PNG_READ_tEXt_SUPPORTED
  270. #define PNG_READ_tIME_SUPPORTED
  271. #define PNG_READ_tRNS_SUPPORTED
  272. #define PNG_READ_zTXt_SUPPORTED
  273.  
  274. #define PNG_WRITE_bKGD_SUPPORTED
  275. #define PNG_WRITE_cHRM_SUPPORTED
  276. #define PNG_WRITE_gAMA_SUPPORTED
  277. #define PNG_WRITE_hIST_SUPPORTED
  278. #define PNG_WRITE_oFFs_SUPPORTED
  279. #define PNG_WRITE_pCAL_SUPPORTED
  280. #define PNG_WRITE_pHYs_SUPPORTED
  281. #define PNG_WRITE_sBIT_SUPPORTED
  282. #define PNG_WRITE_tEXt_SUPPORTED
  283. #define PNG_WRITE_tIME_SUPPORTED
  284. #define PNG_WRITE_tRNS_SUPPORTED
  285. #define PNG_WRITE_zTXt_SUPPORTED
  286.  
  287. /* need the time information for reading tIME chunks */
  288. #if defined(PNG_READ_tIME_SUPPORTED) || defined(PNG_WRITE_tIME_SUPPORTED)
  289. #include <time.h>
  290. #endif
  291.  
  292. /* Some typedefs to get us started.  These should be safe on most of the
  293.  * common platforms.  The typedefs should be at least as large as the
  294.  * numbers suggest (a png_uint_32 must be at least 32 bits long), but they
  295.  * don't have to be exactly that size.  Some compilers dislike passing
  296.  * unsigned shorts as function parameters, so you may be better off using
  297.  * unsigned int for png_uint_16.  Likewise, for 64-bit systems, you may
  298.  * want to have unsigned int for png_uint_32 instead of unsigned long.
  299.  */
  300.  
  301. typedef unsigned long png_uint_32;
  302. typedef long png_int_32;
  303. typedef unsigned short png_uint_16;
  304. typedef short png_int_16;
  305. typedef unsigned char png_byte;
  306.  
  307. /* This is usually size_t.  It is typedef'ed just in case you need it to
  308.    change (I'm not sure if you will or not, so I thought I'd be safe) */
  309. typedef size_t png_size_t;
  310.  
  311. /* The following is needed for medium model support.  It cannot be in the
  312.  * PNG_INTERNAL section.  Needs modification for other compilers besides
  313.  * MSC.  Model independent support declares all arrays and pointers to be
  314.  * large using the far keyword.  The zlib version used must also support
  315.  * model independent data.  As of version zlib 1.0.4, the necessary changes
  316.  * have been made in zlib.  The USE_FAR_KEYWORD define triggers other
  317.  * changes that are needed. (Tim Wegner)
  318.  */
  319.  
  320. /* Separate compiler dependencies (problem here is that zlib.h always
  321.    defines FAR. (SJT) */
  322. #ifdef __BORLANDC__
  323. #if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__)
  324. #define LDATA 1
  325. #else
  326. #define LDATA 0
  327. #endif
  328.  
  329. #if !defined(__WIN32__) && !defined(__FLAT__)
  330. #define PNG_MAX_MALLOC_64K
  331. #if (LDATA != 1)
  332. #ifndef FAR
  333. #define FAR __far
  334. #endif
  335. #define USE_FAR_KEYWORD
  336. #endif   /* LDATA != 1 */
  337.  
  338. /* Possibly useful for moving data out of default segment.
  339.    Uncomment it if you want. Could also define FARDATA as
  340.    const if your compiler supports it. (SJT)
  341. #  define FARDATA FAR
  342. */
  343. #endif  /* __WIN32__, __FLAT__ */
  344.  
  345. #endif   /* __BORLANDC__ */
  346.  
  347.  
  348. /* Suggest testing for specific compiler first before testing for
  349.    FAR.  The Watcom compiler defines both __MEDIUM__ and M_I86MM,
  350.    making reliance oncertain keywords suspect. (SJT) */
  351.  
  352. /* MSC Medium model */
  353. #if defined(FAR)
  354. #  if defined(M_I86MM)
  355. #     define USE_FAR_KEYWORD
  356. #     define FARDATA FAR
  357. #     include <dos.h>
  358. #  endif
  359. #endif
  360.  
  361. /* SJT: default case */
  362. #ifndef FAR
  363. #   define FAR
  364. #endif
  365.  
  366. /* At this point FAR is always defined */
  367. #ifndef FARDATA
  368. #define FARDATA
  369. #endif
  370.  
  371. /* Add typedefs for pointers */
  372. typedef void            FAR * png_voidp;
  373. typedef png_byte        FAR * png_bytep;
  374. typedef png_uint_32     FAR * png_uint_32p;
  375. typedef png_int_32      FAR * png_int_32p;
  376. typedef png_uint_16     FAR * png_uint_16p;
  377. typedef png_int_16      FAR * png_int_16p;
  378. typedef PNG_CONST char  FAR * png_const_charp;
  379. typedef char            FAR * png_charp;
  380. typedef double          FAR * png_doublep;
  381.  
  382. /* Pointers to pointers; i.e. arrays */
  383. typedef png_byte        FAR * FAR * png_bytepp;
  384. typedef png_uint_32     FAR * FAR * png_uint_32pp;
  385. typedef png_int_32      FAR * FAR * png_int_32pp;
  386. typedef png_uint_16     FAR * FAR * png_uint_16pp;
  387. typedef png_int_16      FAR * FAR * png_int_16pp;
  388. typedef PNG_CONST char  FAR * FAR * png_const_charpp;
  389. typedef char            FAR * FAR * png_charpp;
  390. typedef double          FAR * FAR * png_doublepp;
  391.  
  392. /* Pointers to pointers to pointers; i.e. pointer to array */
  393. typedef char            FAR * FAR * FAR * png_charppp;
  394.  
  395. /* libpng typedefs for types in zlib. If zlib changes
  396.  * or another compression library is used, then change these.
  397.  * Eliminates need to change all the source files.
  398.  */
  399. typedef charf *         png_zcharp;
  400. typedef charf * FAR *   png_zcharpp;
  401. typedef z_stream FAR *  png_zstreamp; 
  402.  
  403. /* allow for compilation as dll under windows */
  404. #ifdef __WIN32DLL__
  405. #define PNG_EXPORT(type,symbol) __declspec(dllexport) type symbol
  406. #endif
  407.  
  408. #ifndef PNG_EXPORT
  409. #define PNG_EXPORT(t,s) t s
  410. #endif
  411.  
  412.  
  413. /* User may want to use these so not in PNG_INTERNAL. Any library functions
  414.    that are passed far data must be model independent. */
  415.  
  416. #if defined(USE_FAR_KEYWORD)  /* memory model independent fns */
  417. /* use this to make far-to-near assignments */
  418. #   define CHECK   1
  419. #   define NOCHECK 0
  420. #   define CVT_PTR(ptr) (far_to_near(png_ptr,ptr,CHECK))
  421. #   define CVT_PTR_NOCHECK(ptr) (far_to_near(png_ptr,ptr,NOCHECK))
  422. #   define png_strlen _fstrlen
  423. #   define png_memcmp _fmemcmp      /* SJT: added */
  424. #   define png_memcpy _fmemcpy
  425. #   define png_memset _fmemset
  426. #else /* use the usual functions */
  427. #   define CVT_PTR(ptr)         (ptr)
  428. #   define CVT_PTR_NOCHECK(ptr) (ptr)
  429. #   define png_strlen strlen
  430. #   define png_memcmp memcmp     /* SJT: added */
  431. #   define png_memcpy memcpy
  432. #   define png_memset memset
  433. #endif
  434. /* End of memory model independent support */
  435.  
  436. /* Just a double check that someone hasn't tried to define something
  437.  * contradictory. 
  438.  */
  439. #if (PNG_ZBUF_SIZE > 65536) && defined(PNG_MAX_MALLOC_64K)
  440. #undef PNG_ZBUF_SIZE
  441. #define PNG_ZBUF_SIZE 65536
  442. #endif
  443.  
  444. #endif /* PNGCONF_H */
  445.  
  446.